﻿/// <reference path="../JScript/jquery-1.6.min.js" />
/// <reference path="../JScript/jquery.easyui.min.js" />
/// <reference path="../JScript/easyui-lang-zh_CN.js" />
/// <reference path="../JScript/AutoResize.js" />
/// <reference path="../JScript/JSUtility.js" />

var url = '../Handler/AjaxHandle.ashx';
$(document).ready(function() {
    UserHandle.InitModule("Mod_EmployeeInfoList");
    alert(UserHandle.ValidationHandle("SEARCH"));
    top.autoResize({ dataGrid: '#employeeList', callback: Initlist, par: {}, method: 'Paged' });
    $("#btnAdd").click(addEmployeeInfo);
    $("#btndetail").bind("click", function() { SeeEmployeeInfo("see"); });
    $("#btnDel").click(DelEmployee);
    $("#btnEdit").bind("click", function() { SeeEmployeeInfo("edit"); });
    $("#btnRefersh").click(function() {
        $('#employeeList').datagrid('reload');
    });
});

//添加员工
function addEmployeeInfo() {
    self.parent.addTab("个人信息", "Personnel/EmployeeNavigation.htm", "icon-sys");
}

//查看明细
function SeeEmployeeInfo(type) {
    if (type == "see") {
        type = "&type=see";
    }
    else {
        type = "&type=edit";
    }
    var rows = $("#employeeList").datagrid('getSelections');
    var num = rows.length;
    if (num == 0) {
        $.messager.alert('提示', '请选择一条记录进行操作!', 'info');
        return;
    }
    else {
        self.parent.addTab("个人信息", "../Personnel/EmployeeNavigation.htm?ID=" + rows[0].Id + type, "icon-sys");

    }
}

function DelEmployee() {
    $.messager.confirm('提示信息', '您确认要删除吗?', function(data) {
        if (data) {
            var p = { AssemblyName: "OA.Bll.Personnel", ClassName: "OA.Bll.Personnel.EmployeePresenter", Method: "Delete", Options: {} };
            var rows = $("#employeeList").datagrid('getSelections');
            p.Options["Id"] = rows[0].ID;
            $.ajax({
                type: "post",
                url: "../Handler/AjaxHandle.ashx",
                data: $.toJSON(p),
                dataType: "json",
                success: function(r) {
                    $('#employeeList').datagrid('reload');
                    $.messager.alert('提示', r.msg, 'info');
                }
            });
        }
    });
}

function comboboxInitial() {
    $('#cmbProjectType').combobox({
        url: "http://www.baidu.com",
        valueField: 'id',
        textField: 'text'
    });
    $('#cmbProjectAreaProvines').combobox({
        url: "http://www.baidu.com",
        valueField: 'id',
        textField: 'text'
    });
    $('#cmbProjectPropertyID').combobox({
        url: 'http://www.baidu.com',
        valueField: 'id',
        textField: 'text'
    });
    $('#cmbProjectLevelID').combobox({
        url: 'http://www.google.com',
        valueField: 'id',
        textField: 'text'
    });
}

function Initlist(op, method, size) {
    var p = { AssemblyName: "OA.Bll.Personnel", ClassName: "OA.Bll.Personnel.EmployeePresenter", Method: method, Options: op };
    $('#employeeList').datagrid({
        width: size.width,
        height: size.height,
        pageSize: Math.round(size.height / 25),
        pageList: [Math.round(size.height / 25)],
        striped: true,
        queryParams: { "json": $.toJSON(p) },
        url: url,
        //        frozenColumns: [[{ field: 'ck', checkbox: true }]],
        singleselect: true
    });
}

function AddProjectInfo() {
    $('#Add').window({ title: '员工基本信息维护', closed: false });
}
function UpdateProjectInfo() {
    $('#Add').window({ title: '修改项目基本信息', closed: false });
}
function SearchProjectInfo() {
    $('#Add').window({ title: '查询项目基本信息', closed: false });
}